package org.finesys.chat.core.base.json;

import java.math.BigDecimal;
import java.math.BigInteger;

public class TypeUtils {

    public TypeUtils() {
    }

    public static boolean isJsonInteger(Class<?> type) {
        return type == Byte.TYPE || type == Byte.class || type == Short.TYPE || type == Short.class || type == Integer.TYPE || type == Integer.class || type == Long.TYPE || type == Long.class || type == BigInteger.class;
    }

    public static boolean isJsonNumber(Class<?> type) {
        return type == Float.TYPE || type == Float.class || type == Double.TYPE || type == Double.class || type == BigDecimal.class;
    }

    public static boolean isJsonBoolean(Class<?> type) {
        return type == Boolean.TYPE || type == Boolean.class;
    }

    public static boolean isJsonString(Class<?> type) {
        return type == String.class || type == Character.TYPE || type == Character.class || CharSequence.class.isAssignableFrom(type);
    }

    public static boolean isJsonArray(Class<?> type) {
        return type.isArray() || Iterable.class.isAssignableFrom(type);
    }
}
